//
//  AirSurfaceRender.h
//  AirSurfaceKit
//
//  Created by 李牧 on 16/4/28.
//  Copyright © 2016年 SimuTech. All rights reserved.
//

#import "AirSurfaceRender+Declare.h"

@interface AirSurfaceRender : NSObject
@property (nonatomic, strong) id<AirScalingFactorDelegate> delegate;
@property (nonatomic, strong) DidSelectedBlock selectedBlock;
@property (nonatomic, strong, readonly) NSMutableArray      * selectionArray;
@property (nonatomic, strong, readonly) NSMutableArray      * loadedGuidArray;
@property (nonatomic, strong, readonly) NSMutableDictionary * loadedSegmentList;
@property (nonatomic, strong, readonly) NSProgress          * progress;

/**
 *  移动灵敏度
 */
@property (nonatomic, assign, readonly) float               deault_sensitivity;
/**
 *  控件序列号
 */
@property (nonatomic, strong, readonly) NSString            *   airSurfaceId;

/** 漫游设置
 *  移动方式：1 飞行 2 步行
 */
@property (nonatomic, assign) MoveMode moveMode;

/** 漫游设置
 *  控制模式:0 方向 1 动力
 */
@property (nonatomic, assign) ControlMode controlMode;
@property (nonatomic, strong) UIView    * controlView;
/**
 *  转换带结构的3GD文件
 *
 *  @param file     待转换的文件
 *  @param tempPath 输出文件路径
 *
 *  @return 0 失败 1 转换成功 2 不需要转换
 */
+ (int)convertBigGDfile:(const char*)file tempPath:(const char*)tempPath;

/**
 *  Users must implement createAirSurfaceRender to return a pointer to their derived AirSurfaceRender
 *  Please confirm the validation of the 'AirSurfaceEngine' before use.
  * 
 *  @param surfaceId surfaceId description
 *
 *  @return AirSurfaceRender
 */
+ (AirSurfaceRender *)createAirSurfaceRender:(NSString*)surfaceId;

/**
 *  绑定控件
 *
 *  @param pSurface 指定的UIView
 *
 *  @return 绑定是否成功
 */
- (bool)bind:(void*)pSurface;

/**
 *  清空场景
 */
- (void)emptyScene;

/**
 *  任一显式更新view的操作后请调用refresh
 */
- (void)refresh;

#pragma mark - Touch Down/Move/Up Input Events
/**
 *  输入事件 Touch Down/Move/Up
 *
 *  @param toucheArray    touche Array
 *  @param withTouchType  @see also withTouchType
 *  @param view           被绑定的view
 */
- (void)touchSurface:(NSArray*)toucheArray
           nTapCount:(int)nTapCount
       withTouchType:(TouchEventType)withTouchType
              inView:(UIView*)inView;
/**
 *  取消触摸
 *  需要在系统touchesCancel协议里被调用
 */
- (void)touchesCancel;

#pragma mark -
#pragma mark - Setter
/**
 *  点击部件后将进行回调
 *
 *  @param selectedBlock 回调块
 */
- (void)setSelectedBlock:(DidSelectedBlock)selectedBlock;

/**
 *  裁剪设置
 *	@param bState：true－当模型像素等于unPixel的值就被裁剪掉。false则不会
 *	@param unPixel：如果bState设置为true，则模型为该像素值的时候被裁剪掉
 */
- (void)setFramerate:(bool)bState unPixel:(unsigned int)unPixel;

/** 
 *  是否剔除模型背面
 *	@param bBackFace：true－则剔除模型背面。false则不剔除
 */
- (void)setBackFace:(bool)bBackFace;

/** 
 *  设置抗锯齿
 *	@param bAntiAlias：true－则unValue传入的值有效，值越大模型越光滑，false则不抗锯齿
 *	@param unValue：抗锯齿的值，系统默认为4
 */
- (void)setAntiAlias:(bool)bAntiAlias unValue:(unsigned int)unValue;

/**
 *  设置边线加强
 *
 *  @param FastSilhouette true为加强，false为不加强
 *
 *  @return 1成功 0 失败
 */
- (bool)setEffectsFastSilhouette:(bool)fastSilhouette;

/**
 *  是否显示坐标轴
 *
 *  @param visible visible description
 */
- (void)setAxisTriadVisible:(bool)visible;

/**
 *  设置视图模式
 *	@param nViewMode:视图模式整型值。0-Front Right Top，1-Front，2-Back，3－Left，4-Right，5－Top，6-Bottom
 */
- (void)setViewMode:(ViewMode)nViewMode;

#pragma mark -
#pragma mark - Loading File

/**
 *  异步加载文件模型
 *
 *  @param filePath         文件绝对路径
 *  @param waitUntilDone    是否等待完成
 *  @param completion       完成块
 */
- (void)loadModelFile:(NSString*)filePath
        waitUntilDone:(bool)wait
           completion:(void (^)(BOOL finished))completion;

/**
 *  卸载模型
 *
 *  @param filePath 绝对路径
 *  @param completion 完成后的block块
 */
- (void)unloadModelFile:(NSString*)guid completion:(void (^)(BOOL finished))completion;

/**
 *  刷新加载guid列表
 *
 */
- (void)refreshLoadedSegmentList;

#pragma mark -
#pragma mark - Camara

/**
 *  设置相机投影模式
 *
 *  @param type 0 对应正投影（Orthographic）。
                1 对应透视投影（Perspective)，默认为1透视投影。设置其他值都视为设置透视投影。
 *
 *  @return 0：成功 1：失败
 */
- (bool)setCamaraProjection:(int)type;

/**
 *  设置摄像机的视野
 *
 *  @param width  视野的宽度
 *  @param height 视野的高度
 *
 *  @return 0：成功 1：失败
 */
- (bool)setCamaraField:(float)width height:(float)height;

#pragma mark -
#pragma mark - Selection

/**
 *  选中指定guid
 *
 *  @param segmentArray AirSegmentKey数组
 *
 *  @return 选中数量
 */
- (int)setSelection:(NSArray *)segmentArray;

/**
 *  取消选中guid
 *
 *  @param segmentArray AirSegmentKey数组
 *
 *  @return 反选数量
 */
- (void)setUnSelection:(NSArray *)segmentArray;

/**
 *  反选全部
 */
- (void)unsetSelection;

#pragma mark -
#pragma mark - Zoom

/**
 *  缩放相机
 *
 *  @param zoomMode 缩放相机模式 @see also ZoomMode
 */
- (void)setZoomCamara:(ZoomMode)zoomMode;

#pragma mark -
#pragma mark - 漫游

- (void)openFPPOV;
- (void)closeFPPOV;
- (void)openObserver;
- (void)closeObserver;
- (void)reloadFirstPersonPOV;

- (void)setFirstPersonPOVMoveMode:(MoveMode)moveMode
                      controlView:(UIView*)controlView;
- (void)touchesBeganFirstPersonPOV:(NSSet *)touches withEvent:(UIEvent *)event withControlMode:(ControlMode)controlMode;
- (void)touchesMovedFirstPersonPOV:(NSSet *)touches withEvent:(UIEvent *)event withControlMode:(ControlMode)controlMode;
- (void)touchesEndFirstPersonPOV:(NSSet *)touches;
- (void)setScalingFactorFirstPersonPOV:(float)scalingFactor;

#pragma mark -
#pragma mark - 性能测试
/**
 *  性能测试
 */
- (void)testPerformance;
@end
